package com.yonyou.sto.modules.ums.util;

import cn.hutool.core.util.StrUtil;
import com.yonyou.sto.modules.ums.dto.UmsNcCusttaxParam;
import com.yonyou.sto.modules.ums.model.UmsNcCusttax;
import com.yonyou.sto.modules.ums.model.UmsNcMategrade;

import java.util.ArrayList;
import java.util.List;

public class NcMateGradeUtil {

    public static void toOrigin(UmsNcMategrade umsNcMategrade){
        umsNcMategrade.setCusttax1("0");
        umsNcMategrade.setCusttax2("0");
        umsNcMategrade.setCusttax3("0");
        umsNcMategrade.setCusttax4("0");
        umsNcMategrade.setCusttax5("0");
        umsNcMategrade.setCusttax6("0");
        umsNcMategrade.setCusttax7("0");
        umsNcMategrade.setCusttax8("0");
        umsNcMategrade.setCusttax9("0");
        umsNcMategrade.setCusttax10("0");
        umsNcMategrade.setCusttax11("0");
        umsNcMategrade.setCusttax12("0");
        umsNcMategrade.setCusttax13("0");
        umsNcMategrade.setCusttax14("0");
        umsNcMategrade.setCusttax15("0");
    };


    public static boolean setMateName(UmsNcMategrade umsNcMategrade){
        List<String> matename = umsNcMategrade.getMatename();
        int i = 0;
        for (String custMateName : matename) {
            switch (custMateName){
                case "CUSTTAX1":
                    umsNcMategrade.setCusttax1("1");
                    i++;
                    break;
                case "CUSTTAX2":
                    umsNcMategrade.setCusttax2("1");
                    i++;
                    break;
                case "CUSTTAX3":
                    umsNcMategrade.setCusttax3("1");
                    i++;
                    break;
                case "CUSTTAX4":
                    umsNcMategrade.setCusttax4("1");
                    i++;
                    break;
                case "CUSTTAX5":
                    umsNcMategrade.setCusttax5("1");
                    i++;
                    break;
                case "CUSTTAX6":
                    umsNcMategrade.setCusttax6("1");
                    i++;
                    break;
                case "CUSTTAX14":
                    umsNcMategrade.setCusttax14("1");
                    i++;
                    break;
            }
        }
        return i==matename.size();
    }

    public static List<String> getMateName(UmsNcMategrade umsNcMategrade){
        int i = 0;
        List<String> matename=new ArrayList<>();
        for (int j=1;j<=7;j++){
            switch (j){
                case 1:
                    String custtax1 = umsNcMategrade.getCusttax1();
                    if (StrUtil.isNotBlank(custtax1)&&StrUtil.isNotEmpty(custtax1)){
                        if ("1".equals(custtax1)){
                            matename.add("CUSTTAX1");
                            i++;
                        }
                    }
                    break;
                case 2:
                    String custtax2 = umsNcMategrade.getCusttax2();
                    if (StrUtil.isNotBlank(custtax2)&&StrUtil.isNotEmpty(custtax2)){
                        if ("1".equals(custtax2)){
                            matename.add("CUSTTAX2");
                            i++;
                        }
                    }
                    break;
                case 3:
                    String custtax3 = umsNcMategrade.getCusttax3();
                    if (StrUtil.isNotBlank(custtax3)&&StrUtil.isNotEmpty(custtax3)){
                        if ("1".equals(custtax3)){
                            matename.add("CUSTTAX3");
                            i++;
                        }
                    }
                    break;
                case 4:
                    String custtax4 = umsNcMategrade.getCusttax4();
                    if (StrUtil.isNotBlank(custtax4)&&StrUtil.isNotEmpty(custtax4)){
                        if ("1".equals(custtax4)){
                            matename.add("CUSTTAX4");
                            i++;
                        }
                    }
                    break;
                case 5:
                    String custtax5 = umsNcMategrade.getCusttax5();
                    if (StrUtil.isNotBlank(custtax5)&&StrUtil.isNotEmpty(custtax5)){
                        if ("1".equals(custtax5)){
                            matename.add("CUSTTAX5");
                            i++;
                        }
                    }
                    break;
                case 6:
                    String custtax6 = umsNcMategrade.getCusttax6();
                    if (StrUtil.isNotBlank(custtax6)&&StrUtil.isNotEmpty(custtax6)){
                        if ("1".equals(custtax6)){
                            matename.add("CUSTTAX6");
                            i++;
                        }
                    }
                    break;
                case 7:
                    String custtax14 = umsNcMategrade.getCusttax14();
                    if (StrUtil.isNotBlank(custtax14)&&StrUtil.isNotEmpty(custtax14)){
                        if ("1".equals(custtax14)){
                            matename.add("CUSTTAX14");
                            i++;
                        }
                    }
                    break;
            }
        }
        return i == matename.size() ? matename : null;
    }

    public static boolean setSpecModel(UmsNcMategrade umsNcMategrade){
        List<String> specModels = umsNcMategrade.getSpecModel();
        int i = 0;
        for (String specModel : specModels) {
            switch (specModel){
                case "CUSTTAX7":
                    umsNcMategrade.setCusttax7("1");
                    i++;
                    break;
                case "CUSTTAX8":
                    umsNcMategrade.setCusttax8("1");
                    i++;
                    break;
                case "CUSTTAX9":
                    umsNcMategrade.setCusttax9("1");
                    i++;
                    break;
                case "CUSTTAX10":
                    umsNcMategrade.setCusttax10("1");
                    i++;
                    break;
                case "CUSTTAX11":
                    umsNcMategrade.setCusttax11("1");
                    i++;
                    break;
                case "CUSTTAX12":
                    umsNcMategrade.setCusttax12("1");
                    i++;
                    break;
                case "CUSTTAX13":
                    umsNcMategrade.setCusttax13("1");
                    i++;
                    break;
                case "CUSTTAX15":
                    umsNcMategrade.setCusttax15("1");
                    i++;
                    break;
            }
        }
        return i==specModels.size();
    }

    public static List<String> getSpecModel(UmsNcMategrade umsNcMategrade){
        int i = 0;
        List<String> specModels=new ArrayList<>();
        for (int j=7;j<=14;j++){
            switch (j){
                case 7:
                    String custtax7 = umsNcMategrade.getCusttax7();
                    if (StrUtil.isNotBlank(custtax7)&&StrUtil.isNotEmpty(custtax7)){
                        if ("1".equals(custtax7)){
                            specModels.add("CUSTTAX7");
                            i++;
                        }
                    }
                    break;
                case 8:
                    String custtax8 = umsNcMategrade.getCusttax8();
                    if (StrUtil.isNotBlank(custtax8)&&StrUtil.isNotEmpty(custtax8)){
                        if ("1".equals(custtax8)){
                            specModels.add("CUSTTAX8");
                            i++;
                        }
                    }
                    break;
                case 9:
                    String custtax9 = umsNcMategrade.getCusttax9();
                    if (StrUtil.isNotBlank(custtax9)&&StrUtil.isNotEmpty(custtax9)){
                        if ("1".equals(custtax9)){
                            specModels.add("CUSTTAX9");
                            i++;
                        }
                    }
                    break;
                case 10:
                    String custtax10 = umsNcMategrade.getCusttax10();
                    if (StrUtil.isNotBlank(custtax10)&&StrUtil.isNotEmpty(custtax10)){
                        if ("1".equals(custtax10)){
                            specModels.add("CUSTTAX10");
                            i++;
                        }
                    }
                    break;
                case 11:
                    String custtax11 = umsNcMategrade.getCusttax11();
                    if (StrUtil.isNotBlank(custtax11)&&StrUtil.isNotEmpty(custtax11)){
                        if ("1".equals(custtax11)){
                            specModels.add("CUSTTAX11");
                            i++;
                        }
                    }
                    break;
                case 12:
                    String custtax12 = umsNcMategrade.getCusttax12();
                    if (StrUtil.isNotBlank(custtax12)&&StrUtil.isNotEmpty(custtax12)){
                        if ("1".equals(custtax12)){
                            specModels.add("CUSTTAX12");
                            i++;
                        }
                    }
                    break;
                case 13:
                    String custtax13 = umsNcMategrade.getCusttax13();
                    if (StrUtil.isNotBlank(custtax13)&&StrUtil.isNotEmpty(custtax13)){
                        if ("1".equals(custtax13)){
                            specModels.add("CUSTTAX13");
                            i++;
                        }
                    }
                    break;
                case 14:
                    String custtax15 = umsNcMategrade.getCusttax15();
                    if (StrUtil.isNotBlank(custtax15)&&StrUtil.isNotEmpty(custtax15)){
                        if ("1".equals(custtax15)){
                            specModels.add("CUSTTAX15");
                            i++;
                        }
                    }
                    break;
            }
        }
        return i == specModels.size() ? specModels : null;
    }
}
